package tote.context;

import javax.sql.DataSource;

import org.springframework.context.ApplicationContext;

/**
 * This class provides application-wide access to the Spring ApplicationContext. The ApplicationContext is injected by
 * the class "ApplicationContextProvider".
 * 
 * @author Siegfried Bolz
 */
public class AppContext {

    private static ApplicationContext ctx;
    // private static AppUserDetails userdetails;
    private static DataSource dataSource;

    /**
     * Injected from the class "ApplicationContextProvider" which is automatically loaded during Spring-Initialization.
     */
    public static void setApplicationContext(ApplicationContext applicationContext) {
	ctx = applicationContext;
    }

    /**
     * Get access to the Spring ApplicationContext from everywhere in your Application.
     * 
     * @return
     */
    public static ApplicationContext getApplicationContext() {
	return ctx;
    }

    // public static void setUserDetails(AppUserDetails userdetails) {
    // AppContext.userdetails = userdetails;
    // }
    //
    // public static AppUserDetails getUserDetails() {
    // return AppContext.userdetails;
    // }

    public static void setDataSource(DataSource dataSource) {
	AppContext.dataSource = dataSource;
    }

    public static DataSource getDataSource() {
	return dataSource;
    }

} // .EOF